package studio.raptor.extractor.segment.properties;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * Created by liuyong8 on 2017/7/18.
 */
public class ZKProperties {
  /**
   * 连接Zookeeper服务器的列表. 包括IP地址和端口号. 多个地址用逗号分隔. 如: host1:2181,host2:2181
   */
  @Value("${extractor.zk.servers}")
  private String servers;

  /**
   * 命名空间.
   */
  @Value("${extractor.zk.namespace}")
  private String namespace;

  /**
   * 等待重试的间隔时间的初始值. 单位毫秒.
   */
  @Value("${extractor.zk.baseSleepTimeMilliseconds: 1000}")
  private int baseSleepTimeMilliseconds;

  /**
   * 等待重试的间隔时间的最大值. 单位毫秒.
   */
  @Value("${extractor.zk.maxSleepTimeMilliseconds: 3000}")
  private int maxSleepTimeMilliseconds = 3000;

  /**
   * 最大重试次数.
   */
  @Value("${extractor.zk.maxRetries: 3}")
  private int maxRetries = 3;

  /**
   * 会话超时时间. 单位毫秒.
   */
  @Value("${extractor.zk.sessionTimeoutMilliseconds: 3000}")
  private int sessionTimeoutMilliseconds;

  /**
   * 连接超时时间. 单位毫秒.
   */
  @Value("${extractor.zk.connectionTimeoutMilliseconds: 30000}")
  private int connectionTimeoutMilliseconds;

  /**
   * 连接Zookeeper的权限令牌. 缺省为不需要权限验证.
   */
  @Value("${extractor.zk.digest: ''}")
  private String digest;

  public String getServers() {
    return servers;
  }

  public void setServers(String servers) {
    this.servers = servers;
  }

  public String getNamespace() {
    return namespace;
  }

  public void setNamespace(String namespace) {
    this.namespace = namespace;
  }

  public int getBaseSleepTimeMilliseconds() {
    return baseSleepTimeMilliseconds;
  }

  public void setBaseSleepTimeMilliseconds(int baseSleepTimeMilliseconds) {
    this.baseSleepTimeMilliseconds = baseSleepTimeMilliseconds;
  }

  public int getMaxSleepTimeMilliseconds() {
    return maxSleepTimeMilliseconds;
  }

  public void setMaxSleepTimeMilliseconds(int maxSleepTimeMilliseconds) {
    this.maxSleepTimeMilliseconds = maxSleepTimeMilliseconds;
  }

  public int getMaxRetries() {
    return maxRetries;
  }

  public void setMaxRetries(int maxRetries) {
    this.maxRetries = maxRetries;
  }

  public int getSessionTimeoutMilliseconds() {
    return sessionTimeoutMilliseconds;
  }

  public void setSessionTimeoutMilliseconds(int sessionTimeoutMilliseconds) {
    this.sessionTimeoutMilliseconds = sessionTimeoutMilliseconds;
  }

  public int getConnectionTimeoutMilliseconds() {
    return connectionTimeoutMilliseconds;
  }

  public void setConnectionTimeoutMilliseconds(int connectionTimeoutMilliseconds) {
    this.connectionTimeoutMilliseconds = connectionTimeoutMilliseconds;
  }

  public String getDigest() {
    return digest;
  }

  public void setDigest(String digest) {
    this.digest = digest;
  }

  @Override
  public String toString() {
    return "ZookeeperConfiguration{" + "servers='" + servers + '\'' + ", namespace='" + namespace
        + '\'' + ", baseSleepTimeMilliseconds=" + baseSleepTimeMilliseconds
        + ", maxSleepTimeMilliseconds=" + maxSleepTimeMilliseconds + ", maxRetries=" + maxRetries
        + ", sessionTimeoutMilliseconds=" + sessionTimeoutMilliseconds
        + ", connectionTimeoutMilliseconds=" + connectionTimeoutMilliseconds + ", digest='" + digest
        + '\'' + '}';
  }
}
